import { request } from '../../request'

export type ArticleCategoryQueryParamsType = ApiModels.IBaseQueryParams & {
  pid?: string
  visible?: boolean | string
}

/**
 * 获取资讯类别分页列表
 * @param params - 查询参数
 */
export function fetchArticleCategoryList(params?: ArticleCategoryQueryParamsType) {
  return request.get<ApiModels.PageList<ApiModels.base.ArticleCategory>>('/base/articleCategories/list', { params })
}

/**
 * 获取资讯类别节点列表
 * @param params - 查询参数
 */
export function fetchArticleCategoryNodeList(params?: { pid?: string; visible?: boolean | string; keyword?: string }) {
  return request.get<ApiModels.PageList<ApiModels.base.ArticleCategory>>('/base/articleCategories/nodeList', {
    params,
  })
}

/**
 * 获取资讯类别详情
 * @param num - 资讯类别编号
 */
export function fetchArticleCategoryDetail(num: string) {
  return request.get<ApiModels.base.ArticleCategory>(`/base/articleCategories/get/${num}`)
}

/**
 * 新增资讯类别
 * @param data - 资讯类别模型
 */
export function createArticleCategory(data: ApiModels.base.ArticleCategory) {
  return request.post<ApiModels.base.ArticleCategory>('/base/articleCategories/create', data)
}

/**
 * 更新资讯类别
 * @param data - 资讯类别模型
 */
export function updateArticleCategory(data: ApiModels.base.ArticleCategory) {
  return request.put<ApiModels.base.ArticleCategory>('/base/articleCategories/update', data)
}

/**
 * 删除资讯类别
 * @param num - 资讯类别编号
 */
export function deleteArticleCategory(num: string) {
  return request.delete<ApiModels.base.ArticleCategory>(`/base/articleCategories/delete/${num}`)
}
